var num=0;
var ox=350;
var oy=340;
var aa1,aa2,aa3,aa4,aa5,bb1,bb2,bb3,bb4,bb5;
var x=new array();
var y=new array();
var tempmaxx,tempminx,tempmaxy,tempminy;

function initialize() {	
   _root.createEmptyMovieClip ("mymc", 2);//建立绘图对象
   a0="";a1="";a2="";a3="";a4="";a5="";
   b0="";b1="";b2="";b3="";b4="";b5="";
   x1="";x2="";x3="";x4="";
   y1="";y2="";y3="";y4="";
   xxx=0;
   setproperty("w1",_visible,"0");
   setproperty("w0",_visible,"0");
 }

function getdata(){
	num=0;
	if (aa0==0 ){w=0.01;setproperty("w1",_visible,"1");}
	else {w=0;setproperty("w0",_visible,"1");}
	while (w<=5000) {
	tht1 = bb0-bb2*w*w+bb4*w*w*w*w;
	tht2 = bb1*w-bb3*w*w*w+bb5*w*w*w*w*w;
	tht3 = aa0-aa2*w*w+aa4*w*w*w*w;
	tht4 = aa1*w-aa3*w*w*w+aa5*w*w*w*w*w;
	x[num] = (tht1*tht3+tht2*tht4)/(tht3*tht3+tht4*tht4);
	y[num]= (tht2*tht3-tht1*tht4)/(tht3*tht3+tht4*tht4);
	if(w<5){w=w+0.01;}else if(w<100){w=w+0.5;}else{w=w+10}
	num=num+1;
	}
}


function getmax_xy(){
	tempmaxx=Math.abs(x[0]);tempminx=Math.abs(x[0]);
	tempmaxy=Math.abs(y[0]);tempminy=Math.abs(y[0]);
	for (j=1;j<num;j=j+1)
	   {  if (tempmaxx<Math.abs(x[j])){tempmaxx=Math.abs(x[j])};if (tempminx>Math.abs(x[j])){temptminx=Math.abs(x[j])};
		  if (tempmaxy<Math.abs(y[j])){tempmaxy=Math.abs(y[j])};if (tempminy>Math.abs(y[j])){temptminy=Math.abs(y[j])};
	   }
	   tempmaxx=Math.round(tempmaxx);
	   tempmaxy=Math.round(tempmaxy);
}

function drawaxis(){
	if (tempmaxx==0) {tempmaxx=1;}
	if (tempmaxy==0) {tempmaxy=1;}
	dx=200/(1.0*tempmaxx);
	dy=160/(1.0*tempmaxy);
	x1=-tempmaxx;x2=x1/2;x3=-x2;x4=-x1;
	y1=-tempmaxy;y2=y1/2;y3=-y2;y4=-y1;
}

function drawLine(i) {
	clr=new array(0xffff00,0xff00,0xffff,0xff00ff);
    with(_root.mymc) {
		linestyle(2, clr[i], 100);
		moveTo(ox+dx*x[0],oy-dy*y[0]);
		setproperty("w0",_x,ox+dx*x[0]);
		setproperty("w0",_y,oy-dy*y[0]);
		setproperty("w1",_x,ox+dx*x[0]);
		setproperty("w1",_y,oy-dy*y[0]);
		for(j=0;j<num;j++) {
			lineTo(ox+dx*x[j],oy-dy*y[j]);}
		linestyle(2, 0xff0000, 100);
		/*moveTo(ox+dx*x[19],oy-dy*y[19]);
		lineTo(ox+dx*x[19],oy-dy*y[10]);
		moveTo(ox+dx*x[19],oy-dy*y[19]);
		lineTo(ox+dx*x[10],oy-dy*y[19]);*/
		}
			
};



initialize();

//////

//////////


BTNInput2.onRelease = function() {
 		if (a0 eq "") {	aa0 = 0;} else {aa0 = a0;}
		if (a1 eq "") {	aa1 = 0;} else {aa1 = a1;}
		if (a2 eq "") {	aa2 = 0;} else {aa2 = a2;}
		if (a3 eq "") {aa3 = 0;	} else {aa3 = a3;}
		if (a4 eq "") {	aa4 = 0;} else {aa4 = a4;}
		if (a5 eq "") {aa5 = 0;	} else {aa5 = a5;}
		if (b0 eq "") {	bb0 = 0;} else {bb0 = b0;}
		if (b1 eq "") {	bb1 = 0;} else {bb1 = b1;}
		if (b2 eq "") {	bb2 = 0;} else {bb2 = b2;}
		if (b3 eq "") {	bb3 = 0;} else {bb3 = b3;}
		if (b4 eq "") {	bb4 = 0;} else {bb4 = b4;}
		if (b5 eq "") {	bb5 = 0;} else {bb5 = b5;}
		if (xxx==0){
		if(Math.abs (aa0)+Math.abs (aa1)+Math.abs (aa2)+Math.abs (aa3)+Math.abs (aa4)+Math.abs (aa5)!=0){
		getdata();
		getmax_xy();
		drawaxis();
		drawLine(1);xxx=1;err1=""}
		else{err1="error"}
		}
  }

BTNInput3.onRelease = function() {
	
	initialize();
	err1=""
	xxx=0;
}
